Skip to content

Conversation

@mattt
Copy link
Owner

@mattt mattt commented Jan 5, 2026

Resolves #79

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds JSON mode support for Gemini language models, enabling structured JSON output generation. The implementation introduces a new JSONMode enum with three states: disabled, enabled (basic JSON), and schema-constrained JSON output.

Key changes:

  • Added a JSONMode enum to CustomGenerationOptions with support for basic JSON mode and schema-based JSON output
  • Integrated JSON mode configuration into the Gemini API request generation logic by setting responseMimeType and optionally responseSchema
  • Added comprehensive test coverage for both basic JSON mode and schema-constrained JSON mode

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Sources/AnyLanguageModel/Models/GeminiLanguageModel.swift Implements the JSONMode enum and integrates it into the request generation logic, setting the appropriate Gemini API parameters
Tests/AnyLanguageModelTests/GeminiLanguageModelTests.swift Adds tests for JSON mode functionality, including basic JSON mode and schema-constrained mode

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mattt mattt merged commit f171982 into main Jan 5, 2026
3 checks passed
@mattt mattt deleted the mattt/gemini-json-mode branch January 5, 2026 13:03
mattt added a commit that referenced this pull request Jan 5, 2026
mattt added a commit that referenced this pull request Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add JSON mode support for Gemini models

2 participants